function ComponentPropsSkinSelector(e){if(!window.oBXSkinSelectors)window.oBXSkinSelectors=[];var i;for(var s=0,t=window.oBXSkinSelectors.length;s<t;s++){i=window.oBXSkinSelectors[s];if(!i)continue;if(i.pWnd.parentNode==e.oCont){i.Suicide();i=null}else{if(i.Popup)i.ClosePopup()}}var n=new BXSkinSelector(e);e.oCont.insertBefore(n.pWnd,e.oCont.lastChild);window.oBXSkinSelectors.push(n)}function BXSkinSelector(arParams){jsUtils.loadCSSFile("/bitrix/components/bitrix/player/js/skin_selector.css");var _this=this;this.arElements=arParams.getElements();this.pInput=arParams.oInput;this.fChange=arParams.fChange||false;var jsParams={};try{jsParams=eval(arParams.data)}catch(e){}this.advancedProps=jsParams[2]||[];this.Mess=jsParams[1];this.arSkins=jsParams[0]||[];this.arSkins=[{name:"Default Skin",filename:""}].concat(this.arSkins);this.pWnd=jsUtils.CreateElement("DIV",{className:"bx-skin-select-div"});this.pWnd.onclick=function(){_this.ShowPopup()};setTimeout(function(){_this.OnChange(false,false)},10)}BXSkinSelector.prototype={OnChange:function(e,i){var s=this.pInput.value,t,n=this.arSkins.length;if(!e){for(t=0;t<n;t++){if(this.arSkins[t].filename==s){e=this.arSkins[t];break}}}if(!e){this.pInput.value="";return this.OnChange()}while(this.pWnd.firstChild)this.pWnd.removeChild(this.pWnd.firstChild);if(i!==false&&this.fChange&&typeof this.fChange=="function")this.fChange();this.pWnd.appendChild(document.createTextNode(e.name))},ShowPopup:function(){var e=this;if(this.bPopupShowed)return this.ClosePopup();if(!this.Popup)this.CreatePopup();this.Popup.style.display="block";this.bPopupShowed=true;this.Popup.style.zIndex=4e3;var i=BX.pos(this.pWnd);this.pCont=BX("bx_popup_content");if(!this.pCont)this.pCont=jsUtils.FindParentObject(this.pInput,"DIV","c2dialog_propdiv");if(!this.pCont)this.pCont=jsUtils.FindParentObject(this.pInput,"DIV","bxtaskbarprops");if(this.pCont)jsUtils.addEvent(this.pCont,"scroll",window.BX_PLAYER_SKIN_PARAM_CLOSE);jsFloatDiv.Show(this.Popup,i.left,i.top+20,5,false,false);var s=this.arDivs[this.pInput.value||"-"];s.appendChild(this.pSelectMask);if(window.jsPopup)window.jsPopup.DenyClose(true);if(window.GLOBAL_pMainObj){for(var t in GLOBAL_pMainObj){if(typeof GLOBAL_pMainObj[t]=="object"&&GLOBAL_pMainObj[t].pC2PropsDialog)GLOBAL_pMainObj[t].pC2PropsDialog.bDenyClose=true}}jsUtils.addEvent(document,"keypress",window.BX_PLAYER_SKIN_PARAM_CLOSE);setTimeout(function(){jsUtils.addEvent(document,"click",window.BX_PLAYER_SKIN_PARAM_CLOSE)},10)},ClosePopup:function(){this.Popup.style.display="none";this.bPopupShowed=false;jsFloatDiv.Close(this.Popup);jsUtils.removeEvent(document,"keypress",window.BX_PLAYER_SKIN_PARAM_CLOSE);jsUtils.removeEvent(document,"click",window.BX_PLAYER_SKIN_PARAM_CLOSE);if(this.pCont)jsUtils.removeEvent(this.pCont,"scroll",window.BX_PLAYER_SKIN_PARAM_CLOSE);if(window.jsPopup)window.jsPopup.DenyClose(false);if(window.GLOBAL_pMainObj){for(var e in GLOBAL_pMainObj){if(typeof GLOBAL_pMainObj[e]=="object"&&GLOBAL_pMainObj[e].pC2PropsDialog)GLOBAL_pMainObj[e].pC2PropsDialog.bDenyClose=false}}},CreatePopup:function(){var e=this,i,s,t,n=this.arSkins.length;this.arDivs={};this.Popup=document.body.appendChild(BX.create("DIV",{props:{className:"bx-skin-popup"}}));var p=this.Popup.appendChild(BX.create("DIV",{props:{className:"bx-skin-popup-inner"}}));this.pSelectMask=BX.create("DIV",{props:{className:"bx-skin-sel-mask"}});for(i=0;i<n;i++){s=p.appendChild(BX.create("DIV",{props:{id:"bx_par_skin_"+i,className:"bx-preview-pic",title:this.arSkins[i].name}}));pTitle=s.appendChild(BX.create("DIV",{props:{className:"bx-skin-prev-title"},text:this.arSkins[i].name}));if(this.arSkins[i].filename==""){if(this.advancedProps.defaultImage){s.appendChild(jsUtils.CreateElement("IMG",{src:this.advancedProps.defaultImage}))}else{s.appendChild(jsUtils.CreateElement("IMG",{src:"/bitrix/components/bitrix/player/images/default_skin.png"}))}}else if(this.arSkins[i].preview){s.appendChild(jsUtils.CreateElement("IMG",{src:this.arSkins[i].the_path+"/"+this.arSkins[i].preview}))}else{pTitle.className+=" bx-no-preview";s.appendChild(jsUtils.CreateElement("DIV",{className:"bx-skin-no-preview"})).appendChild(document.createTextNode(" - "+this.Mess.NoPreview+" - "))}s.onmouseover=function(){this.className="bx-preview-pic bx-preview-pic-over"};s.onmouseout=function(){this.className="bx-preview-pic"};s.onclick=function(){var i=e.arSkins[this.id.substr("bx_par_skin_".length)];e.pInput.value=i.filename;e.OnChange(i);e.ClosePopup()};this.arDivs[this.arSkins[i].filename||"-"]=s}window.BX_PLAYER_SKIN_PARAM_CLOSE=function(i){e.ClosePopup()}},Suicide:function(){this.ClosePopup();if(this.Popup.parentNode)this.Popup.parentNode.removeChild(this.Popup);if(this.pWnd.parentNode)this.pWnd.parentNode.removeChild(this.pWnd)}};
//# sourceMappingURL=prop_skin_selector.map.js